﻿using System;
using System.Data;
using System.Configuration;

using System.Collections;
using System.Web;
using System.Web.Security;

using System.Web.UI;
using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;
using Component;
public partial class BackEnd_CategorySubModify : System.Web.UI.UserControl
{
    int idCat = 0;
    public string _DigitalError = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        this.rfvtxtNameEL.ErrorMessage = ConstString._NhapNoiDung;
        this.rfvtxtNameVN.ErrorMessage = ConstString._NhapNoiDung;
        idCat = ConvertType.ToInt(QueryHelper.GetQueryString(Request,ConstString._idcat));
    }
    public void cmdLuu_Click(object sender, System.EventArgs e)
    {
        CategorySub catSub = new CategorySub(KetNoiCSDL.session);
        catSub.Name = this.txtNameVN.Text.Trim();
        if (CategorySubDB.TestExistName(ColumCategorySub._Category,idCat,ColumCategorySub._Name, catSub.Name, true) == true)
        {
            this.lbMessage.Text = ConstString.chenTB + ", Tồn tại tên này rồi";
            return;
        }
        if (Config.CheckDigitNumber(this.txtPriority.Text) == false)
        {
            this.txtPriority.Focus();
            _DigitalError = Languages.SearchByKeyWord("ktso");
            return;
        }
        catSub.NameEL = this.txtNameEL.Text.Trim();
        catSub.Category = CategoryDB.GetObjectByid(idCat,true);
        catSub.Priority = ConvertType.ToInt(this.txtPriority.Text.Trim());       
        catSub.Active = ConvertType.ToBool(this.ddlActive.Text.Trim());
        if (CategoryDB.Save(catSub) == 1)
        {
            catSub.UrlAdmin = BackEndQuery._AdminQuery + BackEndQuery._ProductL + "&" + Component.ConstString._idsubcat + "="+catSub.Id.ToString();
            catSub.Save();
            this.lbMessage.Text = ConstString.chenTC;
        }
         Response.Redirect(Request.Url.ToString());
    }
}
